#!/bin/bash -

# vim: ts=4 sts=4 sw=4 et si ai fenc=utf-8
#===============================================================================
# Description :
#      Author : root
#     Created : 2023-11-26 20:59
#===============================================================================
export LANG="en_US.UTF-8"
#set -o nounset

basedir=$(dirname "$(readlink -qe "${BASH_SOURCE[0]}")")
top_dir=$(readlink -qe ${basedir}/../)

if [ "$1" == "-c" ]; then
    ${basedir}/cbuild.sh -a clean
    exit 0
fi

cd ${top_dir}

./scripts/get_filelist.sh
mkdir -p .cbuild
begin_str=$(date)
begin_sec=$(date +%s)
echo "[${begin_str}] begin compile at backend."
echo "[${begin_str}] begin compile at backend." >./.cbuild/compilelog
nohup ${basedir}/cbuild.sh  -g PCAPPP_BUILD_EXAMPLES=off -g PCAPPP_BUILD_TESTS=off -g BUILD_SHARED_LIBS=on -g PCAPPP_USE_DPDK=on >>./.cbuild/compilelog 2>&1
ret=$?
end_str=$(date)
end_sec=$(date +%s)
echo "[${end_str}] result:$ret, during: $(( end_sec - begin_sec )), compile log: .cbuild/compilelog"
echo "[${end_str}] result:$ret, during: $(( end_sec - begin_sec ))" >>./.cbuild/compilelog
